package com.wty.emp.exhandler;

import com.wty.commons.exception.WtyException;
import com.wty.commons.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author:wangtianyu
 * @Date：Created on 2020/4/21 0021 13:55
 */
@RestControllerAdvice
public class EmpExceptionHandlerWty {

    /*插入异常*/
    @ExceptionHandler(value = WtyException.class)
    public Result insert(Exception e){
        return Result.CUSTOM_ERROR(e.getMessage());
    }

    /*系统异常*/
    @ExceptionHandler(value = Exception.class)
    public Result sys(Exception e){
        e.printStackTrace();
        return Result.SYS_ERROR();
    }

}
